package com.baizhi.controller;

import com.baizhi.entity.Role;
import com.baizhi.service.RoleService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @ResponseBody
    @RequestMapping("show")
    public Map show(int page,int limit){
        Map map = new HashMap();
        PageInfo<Role> pageInfo = roleService.showAll(page, limit);
        map.put("code",0);
        map.put("msg","");
        map.put("count",pageInfo.getTotal());
        map.put("data",pageInfo.getList());
        System.out.println("pageInfo = " + pageInfo);

        return map;
    }


    //添加
    @ResponseBody
    @RequestMapping("add")
    public Map add(String username, List<Role> list){
        Map map = new HashMap();

        System.out.println("username = " + username);
        System.out.println("list = " + list);

        return map;


    }


}
